import axios from "axios"
import { CHANGE_CID, CHANNEL_LIST } from "../constants/channels"

export const getChannelListAc = (payload, id) => ({
  type: CHANNEL_LIST,
  payload,
  id
})

export const getChannelList = () => async (dispatch) => {
  const {
    data: {
      data: { channels }
    }
  } = await axios.get('http://geek.itheima.net/v1_0/channels')
  console.log(channels);
  dispatch(getChannelListAc(channels, channels[0].id))
}

export const changCid = (cid) => ({
  type: CHANGE_CID,
    cid
})